package com.crm.mapper.system;

import com.crm.pojo.Business;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface HomePageMapper {
    @Select("select  count(*) from tb_clue  where  create_time>#{beginCreateTime}  and   create_time < #{endCreateTime}")
    Integer queryCluesNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
    @Select("select  count(*) from tb_business  where  create_time>#{beginCreateTime}  and  create_time < #{endCreateTime}")
    Integer queryBusinessNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
    @Select("select  count(*) from tb_contract  where  create_time>#{beginCreateTime}  and  create_time< #{endCreateTime}")
    Integer queryContractNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
    @Select("select  sum(contract_salary) from tb_contract  where  create_time>#{beginCreateTime}  and   create_time< #{endCreateTime}")
    Integer querySalasAmount(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);


    @Select("SELECT count(*) FROM tb_business where create_time BETWEEN #{now} AND #{tomorrow}")
    Integer queryTodayBusinessNum(LocalDate now, LocalDate tomorrow);
    @Select("SELECT count(*) FROM tb_clue where create_time BETWEEN #{now} AND #{tomorrow}")
    Integer queryTodayCluesNum(LocalDate now, LocalDate tomorrow);
    @Select("SELECT count(*) FROM tb_contract where create_time BETWEEN #{now} AND #{tomorrow}")
    Integer queryTodayContractNum(LocalDate now, LocalDate tomorrow);
@Select("SELECT sum(contract_salary) from tb_contract where create_time BETWEEN #{now} AND #{tomorrow}")
    Integer queryTodaySalasAmount(LocalDate now, LocalDate tomorrow);
@Select("SELECT COUNt(*) FROM tb_clue  where   status = 1 and  create_time>#{beginCreateTime}  and   create_time<#{endCreateTime}")
    Integer queryTofollowedCluesNum(LocalDateTime beginCreateTime,LocalDateTime endCreateTime);
    @Select("SELECT COUNt(*) FROM tb_business  where   status = 1 and  create_time>#{beginCreateTime}  and   create_time<#{endCreateTime}")
    Integer queryTofollowedBusinessNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
@Select("SELECT count(*) from tb_clue where status = 3 and  create_time >#{beginCreateTime}  and   create_time<#{endCreateTime}")
    Integer queryToalllcatedCluesNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
@Select("SELECT count(*) from tb_business where status = 3 and  create_time>#{beginCreateTime}  and  create_time< #{endCreateTime}")
    Integer querytoalllcatedBusinessNum(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
@Select("select count(*) from tb_clue where status in (1,2)")
    Integer queryEffectiveCluesNum(LocalDateTime beginTime, LocalDateTime endTime);
    @Select("select  count(*) from tb_business  where  create_time>#{beginTime}  and  create_time < #{endTime} and status in(1,2)")
    Integer queryyxBusinessNum(LocalDateTime beginTime, LocalDateTime endTime);
    @Select("select * from tb_business  where  create_time>#{beginTime}  and  create_time < #{endTime}")
    List<Business> queryBusiness(LocalDateTime beginTime, LocalDateTime endTime);

}
